﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using Chenxin.Lib.Utility;

public partial class PublishDetailInfo : PageBase
{
    string strRecordId = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(Request.Params["RecordId"])) Response.Redirect("~/errorpage.aspx?msg=非法信息ID", true);
            if (!IsPostBack)
            {
                strRecordId = Request.Params["RecordId"].ToString().Trim();
                hidRecordId.Value = strRecordId.ToString();
                Chenxin.Lib.Hr.Entity.Pblish_Info pblish_info = Chenxin.Lib.Hr.BLL.Pblish_Info.GetModel(new Guid(strRecordId));
                BindPublishTable(pblish_info);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("~/errorpage.aspx?msg=" + ex.Message + "", true);
        }
    }

    private void BindPublishTable(Chenxin.Lib.Hr.Entity.Pblish_Info pblish_info)
    {
        StringBuilder sb = new StringBuilder();
        DataSet ds = Chenxin.Lib.Hr.BLL.Attachment.GetList(string.Format(" RelationId = '{0}' and [Type]=30 ", new Guid(strRecordId)));

        sb.Append("<table width=\"100%\" cellspacing=\"1\" class=\"tabsorternew tab_workreport\" id=\"worktable\">");
        sb.Append("<thead>");
        sb.Append("<tr>");
        sb.AppendFormat("<th colspan=\"2\"><span>【标题】 {0}</span></th>", pblish_info.Subject.ToString());
        sb.Append("</tr>");
        sb.Append("</thead>");
        sb.Append("<tbody>");

        sb.Append("<tr>");
        sb.Append("<td style=\"width:180px; vertical-align:1px;\"> ");
        sb.AppendFormat("<div style='padding:22px 0 0 7px;'><span style='line-height:20px;'><span>发送者工号：{0}</span><br>", pblish_info.PublisherCode.ToString());
        sb.AppendFormat("<span>发送者姓名：{0}</span><br>", pblish_info.PublisherName.ToString());
        sb.AppendFormat("<span>发送部门：{0}</span><br>", pblish_info.DepartName.ToString());
        sb.AppendFormat("<span>发送时间：{0}</span><br>", pblish_info.PublishTime.ToString());
        sb.AppendFormat("<span>建档时间：{0}</span><br>", pblish_info.Addtime.ToString());
        if (ds.Tables[0].Rows.Count != 0 && System.IO.File.Exists(Server.MapPath(Constants.DIRECTORY + ds.Tables[0].Rows[0]["Path"].ToString())))
            sb.AppendFormat("<span>附件：<a id=\"abtnreply\" href=\"/service/Download.ashx?file={0}\" title=\"{1}\">{1}</a></span><br>", ds.Tables[0].Rows[0]["Path"].ToString(), ds.Tables[0].Rows[0]["FileName"].ToString());
        else
            sb.Append("<span>附件：无附件</span><br>");
        sb.Append("</span></div>");
        //if (pblish_info.PublisherId.Equals(CurrentUserInfo.UserId))
        //{
        //    sb.AppendFormat("<div class=\"btn\"><a name='{0}' href=\"#\" title=\"修改\" id=\"btn_edit\"><span>修改</span></a></div>", strRecordId);
        //    sb.AppendFormat("<div class=\"btn\"><a name='{0}' href=\"#\" title=\"删除\" id=\"btn_del\"><span>删除</span></a></div>", strRecordId);
        //}
        sb.AppendFormat("<div class=\"btn\"><a name='{0}' href=\"#\" title=\"修改\" id=\"btn_edit\"><span>修改</span></a></div>", strRecordId);
        sb.AppendFormat("<div class=\"btn\"><a name='{0}' href=\"#\" title=\"删除\" id=\"btn_del\"><span>删除</span></a></div>", strRecordId);
        sb.Append("</td>");
        sb.Append("<td>");
        sb.AppendFormat("<div style='padding:10px;'><span style='line-height:normal;'>{0}</span></div>", Server.UrlDecode(pblish_info.Content.ToString()));
        sb.Append("</td>");
        sb.Append("</tr>");
        sb.Append("</tbody></table>");

        sb.Append("<div style=\"text-align:center\">");
        sb.Append("<div style=\"margin-right:auto; margin-left:auto; width:60px; margin-top:7px;\" ><div class=\"btn\"><a href=\"PublicInfo.aspx?Type=" + pblish_info.InfoType + "\" title=\"返回\" id=\"btn_reply\"><span>返 回</span></a></div></div>");
        sb.Append("</div>");

        this.ltlPublishTable.Text = sb.ToString();
    }
}
